package com.pdsu.graduation_design.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.pdsu.graduation_design.R;

public class PreGridViewAdapter extends BaseAdapter {
    /**
     * 待优化
     * 优化 从后台获取
     */
    private Context context;
    private String[] names = { "助农政策",  "推荐店铺", "新闻公告",  "修改密码", "购物车"};
    private int[] images = {R.drawable.index1, R.drawable.index2, R.drawable.index3, R.drawable.index4, R.drawable.index5};

    public PreGridViewAdapter(Context context) {
        this.context = context;
    }

    @Override
    public int getCount() {
        return images.length;
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        View view = View.inflate(context, R.layout.gridview_item_layout, null);

        ImageView image = view.findViewById(R.id.gv_image);

        TextView title = view.findViewById(R.id.gv_title);

        image.setImageResource(images[position]);

        title.setText(names[position]);

        return view;
    }

}
